var carret=null,fieldobj=null,ie=(document.selection&&document.selection.createRange);
function storepos(obj){ 
   fieldobj=obj; carret=(ie)?document.selection.createRange():null; 
}
function saveScrollCoordinates()
{
	//scrollx = (document.all)?document.body.scrollLeft:window.pageXOffset;
	//scrolly = (document.all)?document.body.scrollTop:window.pageYOffset;
}

function insertAtCarret(str){
   if(!fieldobj) return null;
   if (carret){
      carret.text=str; carret.select();
   } else if(document.getElementById&&!ie) {
      fieldobj.value=fieldobj.value.substring(0,fieldobj.selectionStart)+str+fieldobj.value.substring(fieldobj.selectionEnd);
      fieldobj.focus();
   } else {
      fieldobj.value+=str;
      fieldobj.focus();
   }
}
